/*
 *
 * Select option with id used in callback of ajaxAddOption
 * args - array of arguments to pass onto the functon
 */
function selectID(args){
	$("#id_location_at_owner").selectOptions(args.id);	
}

/*
 *
 * loadOptions(mainSelectID, subSelectID)
 * add options via AJAX 
 * @param mainSelectID - string  for getting selected values from mainSelect
 * @param subSelectID - string for getting selected values in subSelect to change selected 
 */
function loadOptions(mainSelectID, subSelectID){
	var id_owner = $(mainSelectID).selectedValues()[0];
	var id_location_at_owner = $(subSelectID).selectedValues()[0];
    
	$(subSelectID).removeOption(/./);
	$(subSelectID).ajaxAddOption(erpconfig.SELECT_PRODUCT_OWNER + id_owner + "/", {}, false, selectID, [{"id": id_location_at_owner}]);
}

$(document).ready(
    function() {
		loadOptions("#id_owner", "#id_location_at_owner");
    	$("#id_owner").bind("change", function(e){
			loadOptions("#id_owner", "#id_location_at_owner");
		});
	
	}
);
